import { deleteByPrimaryKeyForProResourceAction, selectByPrimaryKeyForProResourceAction, insertForProResourceAction, updateForProResourceAction, deleteByMapForProResourceAction,updateByMapForProResourceAction, getOneForProResourceAction,getAllForProResourceAction,queryPageForProResourceAction, countForProResourceAction, insertBatchForProResourceAction, deleteBatchForProResourceAction,updateBatchForProResourceAction } from '@/services/system/api_proresourceaction';

export default {
    namespace: 'proresourceaction',

    state: {
        data: {
            list: [],
            pagination: {},
        },
    },

    effects: {
            *delete_by_primarykey_for_proresourceaction({ payload }, { call, put }) {
                const response = yield call(deleteByPrimaryKeyForProResourceAction, payload);
                yield put({
                    type: 'deleteByPrimaryKeyForProResourceAction',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProResourceAction, {});
                yield put({
                type: 'queryPageForProResourceAction',
                payload: responsedata,
                });


            },
            *select_by_primarykey_for_proresourceaction({ payload, callback }, { call, put }) {
                const response = yield call(selectByPrimaryKeyForProResourceAction, payload);
                yield put({
                    type: 'selectByPrimaryKeyForProResourceAction',
                    payload: response,
                });


                if (callback) callback();
            },
            *insert_for_proresourceaction({ payload, callback }, { call, put }) {
                const response = yield call(insertForProResourceAction, payload);
                yield put({
                    type: 'insertForProResourceAction',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProResourceAction, {});
                yield put({
                type: 'queryPageForProResourceAction',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *update_for_proresourceaction({ payload, callback }, { call, put }) {
                const response = yield call(updateForProResourceAction, payload);
                yield put({
                    type: 'updateForProResourceAction',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProResourceAction, {});
                yield put({
                type: 'queryPageForProResourceAction',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *delete_by_map_for_proresourceaction({ payload, callback }, { call, put }) {
                const response = yield call(deleteByMapForProResourceAction, payload);
                yield put({
                    type: 'deleteByMapForProResourceAction',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProResourceAction, {});
                yield put({
                type: 'queryPageForProResourceAction',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *update_by_map_for_proresourceaction({ payload, callback }, { call, put }) {
                const response = yield call(updateByMapForProResourceAction, payload);
                yield put({
                    type: 'updateByMapForProResourceAction',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProResourceAction, {});
                yield put({
                type: 'queryPageForProResourceAction',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *get_one_for_proresourceaction({ payload, callback }, { call, put }) {
                const response = yield call(getOneForProResourceAction, payload);
                yield put({
                    type: 'getOneForProResourceAction',
                    payload: response,
                });

                if (callback) callback();
            },
            *get_all_for_proresourceaction({ payload, callback }, { call, put }) {
                const response = yield call(getAllForProResourceAction, payload);
                yield put({
                    type: 'getAllForProResourceAction',
                    payload: response,
                });

                if (callback) callback();
            },
            *query_page_for_proresourceaction({ payload, callback }, { call, put }) {
                const response = yield call(queryPageForProResourceAction, payload);
                yield put({
                    type: 'queryPageForProResourceAction',
                    payload: response,
                });

                if (callback) callback();
            },
            *count_for_proresourceaction({ payload, callback }, { call, put }) {
                const response = yield call(countForProResourceAction, payload);
                yield put({
                    type: 'countForProResourceAction',
                    payload: response,
                });

                if (callback) callback();
            },
            *insert_batch_for_proresourceaction({ payload, callback }, { call, put }) {
                const response = yield call(insertBatchForProResourceAction, payload);
                yield put({
                    type: 'insertBatchForProResourceAction',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProResourceAction, {});
                yield put({
                type: 'queryPageForProResourceAction',
                payload: responsedata,
                });


                if (callback) callback();
            },
            *delete_batch_for_proresourceaction({ payload, callback }, { call, put }) {
                const response = yield call(deleteBatchForProResourceAction, payload);
                yield put({
                    type: 'deleteBatchForProResourceAction',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProResourceAction, {});
                yield put({
                type: 'queryPageForProResourceAction',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *update_batch_for_proresourceaction({ payload, callback }, { call, put }) {
                const response = yield call(updateBatchForProResourceAction, payload);
                yield put({
                    type: 'updateBatchForProResourceAction',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProResourceAction, {});
                yield put({
                type: 'queryPageForProResourceAction',
                payload: responsedata,
                });

                if (callback) callback();
            },
            },

    reducers: {
        deleteByPrimaryKeyForProResourceAction(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        selectByPrimaryKeyForProResourceAction(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        insertForProResourceAction(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateForProResourceAction(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        deleteByMapForProResourceAction(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateByMapForProResourceAction(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        getOneForProResourceAction(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        getAllForProResourceAction(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        queryPageForProResourceAction(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        countForProResourceAction(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        insertBatchForProResourceAction(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        deleteBatchForProResourceAction(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateBatchForProResourceAction(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
    },
};
